﻿Imports System.Web.Mail

Public Class correo
    Public Shared solicituDepto As String
    Public Shared solicitudEmpresa As String
    Public Shared solicitudEmpleadoname As String
    Public Shared correotexto As String
    Public Shared correoasunto As String
    'funcion para ver q tipo de asunto se va enviar
    Public Shared Function asunto(ByVal x As String)

        'nueva solicitud
        If x = 1 Then
            x = "Nueva Solicitud de Servicio"
            Return x
        End If

        'asignacion e nuevo trabajo
        If x = 2 Then
            x = "Asignación de nuevo trabajo"
            Return x
        End If

        If x = 3 Then
            x = "AVISO IMPORTANTE"
            Return x
        End If

        If x = 4 Then
            x = correoasunto
            Return x
        End If
    End Function

    'funcion para saber el tipo de mensaje a mandar por correo
    Public Shared Function mensaje(ByVal y As String)
        If y = 1 Then

            y = "holaaa"
            Return y
        End If

        'Formulario de solicitudes
        If y = 2 Then
            y = "<html><head><title></title></head><body><p style=""text-align: center;"" text-align:=""><u><span style=""><span font-family:="" lucida="" sans="" style="">DEPARTAMENTO DE INFORM&Aacute;TICA Y TECNOLOG&Iacute;A</span></span></u></p><p style=""text-align: center;"" text-align:=""><u><span style=""><span font-family:="" lucida="" sans="" style="">GRUPO INCONHSA</span></span></u></p><p style="" text-align:="">&nbsp;</p><p>		Hola&nbsp; <strong>" & seguridad.tecniconame & "</strong>!!</p><p>HelpDesk le informa que hay una nueva solicitud de servicio en el sistema, procedente de:</p><p><strong>Empresa:   </strong>" & solicitudEmpresa & "</p><p><strong>Departamento:   </strong>" & solicituDepto & "</p><p><strong>Empleado:   </strong>" & solicitudEmpleadoname & "</p></body></html>"

            Return y
        End If
        'Formulario de enviacorreos
        If y = 3 Then
            y = "<html><head><title></title></head><body><p style=""text-align: center;"" text-align:=""><u><span style=""><span font-family:="" lucida="" sans="" style="">DEPARTAMENTO DE INFORM&Aacute;TICA Y TECNOLOG&Iacute;A</span></span></u></p><p style=""text-align: center;"" text-align:=""><u><span style=""><span font-family:="" lucida="" sans="" style="">GRUPO INCONHSA</span></span></u></p><p style=""text-align: center;"" text-align:="">" & correo.correotexto & "</p></body></html>"
            Return y


        End If
    End Function


    Public Shared Function enviacorreos(ByVal toemail As String, ByVal tasunto As String, ByVal tmensaje As String)
        Dim correo As New System.Net.Mail.MailMessage()
        correo.From = New System.Net.Mail.MailAddress("tecnologias@inconhsa.hn", "Sistema HelpDesk")
        correo.Sender = New System.Net.Mail.MailAddress("tecnologias@inconhsa.hn", "Sistema HelpDesk")
        correo.Subject = asunto(tasunto)
        correo.To.Add(toemail)

        correo.Body = mensaje(tmensaje)
        correo.IsBodyHtml = True


        Dim stmp As New System.Net.Mail.SmtpClient
        stmp.Host = "mail.inconhsa.hn"
        stmp.Port = "26"
        stmp.Credentials = New System.Net.NetworkCredential("tecnologias@inconhsa.hn", "conhsa10")
        stmp.EnableSsl = False


        Try

            stmp.Send(correo)



        Catch ex As Exception
            MsgBox("error" & ex.Message)
        End Try

    End Function


    'Dim correo As New System.Net.Mail.MailMessage()
    '    correo.From = New System.Net.Mail.MailAddress("tecnologia@inconhsa.hn", "Soporte Técnico")
    '    correo.Sender = New System.Net.Mail.MailAddress("tecnologia@inconhsa.hn", "Soporte Técnico")
    '    correo.To.Add(txEmail.Text)
    '    correo.Subject = txAsunto.Text
    '    correo.Body = "<html><body><p>" & txMensaje.Text & " </p></body></html>"
    '    correo.IsBodyHtml = True
    '    correo.Priority = Net.Mail.MailPriority.Normal

    'Dim stmp As New System.Net.Mail.SmtpClient
    '    stmp.Host = "190.4.34.91"
    '    stmp.Port = "25"
    '    stmp.Credentials = New System.Net.NetworkCredential("tecnologias", "conhsa10")
    '    stmp.EnableSsl = False

    '    Try
    '        stmp.Send(correo)
    '        txEmail.Text = "mensaje enviado"


    '    Catch ex As Exception
    '        txAsunto.Text = "error" & ex.Message
    '    End Try

End Class
